package io.jsen.meta.diff.obj.ext;

import io.jsen.meta.diff.field.MetaField;
import io.jsen.meta.diff.obj.MetaObject;
import lombok.EqualsAndHashCode;

import static io.jsen.meta.diff.support.MetaChangeModifier.*;

/**
 * @author jsen
 * @date 2021/4/6
 */
@EqualsAndHashCode(callSuper = true)
@SuppressWarnings("all")
public class MetaEnum extends MetaObject<MetaEnum, Enum> {

    public MetaEnum(MetaField field, Enum val) {
        super(field, val);
    }

    @Override
    protected int calState(MetaEnum obj) {
        if (isDelVal()) {
            return setDelete(0);
        }
        return val.compareTo(obj.val) == 0 ? setNoChange(0) : setChange(0);
    }

    @Override
    public String createIndex() {
        return val.toString();
    }
}
